Frameworks: Node is the bedrock upon which many frameworks exist These frameworks built by others are often massive open source projects that then get used by many others. Examples include:
Browserscript: Interacts with the DOM/Cookies/Window
Nodescript: Node works as a server, granting usage to the file system, locally installed packages, environmental control (you can't control what browser the callers are using, but you can control what environment your server's running on).
Module Standards:
Due to the fragmentation of who wrote what when, you'll often see two separate ways of importing modules:
1// ES Module import: 2import moduleObject from 'someModule'xxxxxxxxxx21// CommonJS Module Import2const moduleObject = require("someModule")When exporting data, you can export a default function, or multiple functions to be treated as an object:
someFile.js
xxxxxxxxxx11export default () => "This is a value returned from a function!"someImportingFile.js
x1import whateverNameIWant from './someFile.js'2// const whateverNameIWant = require('./someFile.js')34console.log(whateverNameIWant())someOtherFile.js
xxxxxxxxxx71export const someFunction = () => {2 return "values"3}45export const someOtherFunc = () => {6 return 237}Can be imported as:
xxxxxxxxxx51import * as something from './someOtherFile.js'2// const something = require('someOtherFile.js')34const someValue = something.someFunction()5const someOtherValue = something.someOtherFunc()OR
xxxxxxxxxx51import { someFunction, someOtherFunc } from './someOtherFile.js'2// const { someFunction, someOtherFunc } = require('./someOtherFile.js')34const someValue = someFunction()5const someOtherValue = someOtherFunc()Functions can also be exported as:
defaultExportObject.js
xxxxxxxxxx121const someFunc = () => {2 return 23 3}45const someOtherFunc = () => {6 return [1,2,3,4,5,6]7}89export default {10 someFunc, 11 someOtherFunc12}xxxxxxxxxx31import defaultExportObject from './defaultExportObject.js'23const someNumber = defaultExportObject.someFunc()